package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import bean.*;
import service.*;

@WebServlet("/deleteProduct")
public class DeleteProductServel extends HttpServlet{
	 private static final long serialVersionUID = 1L;
		
		public void doGet(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {

			// 创建水娃服务对象
	        ProductService productService = new ProductService();
	        // 获取全部水娃
	        List<Product> products = productService.findAllProducts();
	        // 获取session对象
	       //System.out.println(products);
	        HttpSession session = request.getSession();
	        // 把水娃列表以属性的方式保存到session里
	        session.setAttribute("products", products);
	        // 重定向到显示水娃页面（deleteProduct.jsp）
	        response.sendRedirect(request.getContextPath() + "/web/backend/deleteProduct.jsp");
	     
	        															  
		}
		
		
		
			
		
		
		public void doPost(HttpServletRequest request, HttpServletResponse response)
				throws ServletException, IOException {
			doGet(request, response);
		
		}
}
